package com.lyz.dataStructure.algorithm.快手2020;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 17:32
 * @Description:
 **/

import java.util.Scanner;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/8/25 17:32
 *@Description:
 **/
public class 版本升级判定 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        for(int i =0;i<n;i++){
            String s1 =sc.next();
            String s2 =sc.next();
            System.out.println(twoCompareVersion(s2,s1));
        }
    }

    public static boolean twoCompareVersion(String s1,String s2){
        String[] num1 = s1.split("\\.");
        String[] num2 = s2.split("\\.");
        int i =0;
        for(;i<num1.length&&i<num2.length;i++){
            int xl1 = Integer.parseInt(num1[i]);
            int xl2 = Integer.parseInt(num2[i]);
            if(xl1<xl2){
                return false;
            }
            if(xl1>xl2){
                return true;
            }
        }
        if(num2.length>num1.length){
            for(;i<num2.length;i++){
                int xl = Integer.parseInt(num2[i]);
                if(xl!=0){
                    return false;
                }
            }
        }else if(num1.length>num2.length){
            for(;i<num1.length;i++){
                int shu = Integer.parseInt(num1[i]);
                if(shu!=0){
                    return true;
                }
            }
        }
        return false;
     }
}
